import React from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import rootRouter from './rootRouter';
import Header from './layout/header';
import Menu from './layout/menu';
import Footer from './layout/footer';

import './index.less';

export default () =>
  (
    <React.Fragment>
      <Header />
      <Router>
        <Menu />
        <div className="mian-content">
          <Switch>
            {
              rootRouter.map((item, index) => (
                <Route
                  key={index}
                  path={item.path}
                  exact={item.exact}
                  component={(props) => {
                    window.g_history = props.history;
                    return (<item.component {...props} />);
                  }}
                />))
            }
            <Route component={() => '404页面'} />
          </Switch>
        </div>
        <Footer />
      </Router>
    </React.Fragment>
  );

